
<!DOCTYPE HTML>
<html lang="en" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>第三章 通信协议 · smartboot 中文指南</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.2">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters-interactive/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="1-消息归类/" />
    
    
    <link rel="prev" href="../chapter-2/SUMMARY.html" />
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"smartboot","repo":"smart-socket","type":"star","size":"small","count":true}]};
    </script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    关于smartboot
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    smart-socket 使用手册
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" >
            
                <span>
            
                    
                    第一章 smart-socket开发指南
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.2.1" data-path="../chapter-1/2.1-基础应用/">
            
                <a href="../chapter-1/2.1-基础应用/">
            
                    
                    1.1 快速上手
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.2" data-path="../chapter-1/2.2-Spring集成/">
            
                <a href="../chapter-1/2.2-Spring集成/">
            
                    
                    1.2 Spring集成smart-socket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.3" data-path="../chapter-1/SUMMARY.html">
            
                <a href="../chapter-1/SUMMARY.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../chapter-2/">
            
                <a href="../chapter-2/">
            
                    
                    第二章 源码解析
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.3.1" data-path="../chapter-2/核心接口/">
            
                <a href="../chapter-2/核心接口/">
            
                    
                    2.1 核心接口与状态机
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3.2" data-path="../chapter-2/服务端/">
            
                <a href="../chapter-2/服务端/">
            
                    
                    2.2 服务端
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3.3" data-path="../chapter-2/客户端/">
            
                <a href="../chapter-2/客户端/">
            
                    
                    2.3 客户端
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3.4" data-path="../chapter-2/AioSession/">
            
                <a href="../chapter-2/AioSession/">
            
                    
                    2.4 会话AioSession
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3.5" data-path="../chapter-2/SUMMARY.html">
            
                <a href="../chapter-2/SUMMARY.html">
            
                    
                    2.5 小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter active" data-level="1.2.4" data-path="./">
            
                <a href="./">
            
                    
                    第三章 通信协议
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.4.1" data-path="1-消息归类/">
            
                <a href="1-消息归类/">
            
                    
                    3.1 消息归类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4.2" data-path="../BLANK.html">
            
                <a href="../BLANK.html">
            
                    
                    3.2 半包/粘包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4.3" data-path="../BLANK.html">
            
                <a href="../BLANK.html">
            
                    
                    3.3 Http消息解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4.4" data-path="../BLANK.html">
            
                <a href="../BLANK.html">
            
                    
                    3.4 RPC消息解析
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../chapter-5/">
            
                <a href="../chapter-5/">
            
                    
                    第四章 内存池
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../chapter-6/">
            
                <a href="../chapter-6/">
            
                    
                    第五章 未来规划
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../end/">
            
                <a href="../end/">
            
                    
                    附录
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    smart-http 实战手册
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../../smart-http/">
            
                <a href="../../smart-http/">
            
                    
                    关于smart-http
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" >
            
                <span>
            
                    
                    第一章 smart-http开发指南
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.2.1" data-path="../../smart-http/chapter-1/">
            
                <a href="../../smart-http/chapter-1/">
            
                    
                    1.1 快速上手
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.2" data-path="../../smart-http/chapter-1/http_route.html">
            
                <a href="../../smart-http/chapter-1/http_route.html">
            
                    
                    1.2 请求路由
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.3" data-path="../../smart-http/chapter-1/file_upload.html">
            
                <a href="../../smart-http/chapter-1/file_upload.html">
            
                    
                    1.3 文件上传/下载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.4" data-path="../../smart-http/chapter-1/websocket.html">
            
                <a href="../../smart-http/chapter-1/websocket.html">
            
                    
                    1.4 WebSocket
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    技术分享
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../../share/rpc/smart-socket-rpc.html">
            
                <a href="../../share/rpc/smart-socket-rpc.html">
            
                    
                    smart-socket实现RPC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../../share/firstfit/readme.html">
            
                <a href="../../share/firstfit/readme.html">
            
                    
                    内存管理-首次适应算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../../share/thread/readme.html">
            
                <a href="../../share/thread/readme.html">
            
                    
                    Thread知多少
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../../donation.html">
            
                <a href="../../donation.html">
            
                    
                    关于捐赠
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >第三章 通信协议</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x7B2C;&#x4E09;&#x7AE0;-&#x901A;&#x4FE1;&#x534F;&#x8BAE;">&#x7B2C;&#x4E09;&#x7AE0; &#x901A;&#x4FE1;&#x534F;&#x8BAE;</h1>
<p>&quot;&#x534F;&#x8BAE;&quot;&#x8FD9;&#x4E2A;&#x8BCD;&#x5728;&#x672C;&#x6587;&#x4E2D;&#x53CD;&#x590D;&#x63D0;&#x53CA;&#xFF0C;&#x901A;&#x4FE1;&#x9886;&#x57DF;&#x4E2D;&#x7684;&#x201D;&#x534F;&#x8BAE;&#x201C;&#x7B49;&#x540C;&#x4E8E;&#x4EBA;&#x4EEC;&#x65E5;&#x5E38;&#x6240;&#x8BA4;&#x77E5;&#x7684;&#x534F;&#x8BAE;&#x6982;&#x5FF5;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;&#x4FDD;&#x5BC6;&#x534F;&#x8BAE;&#xFF0C;&#x5C31;&#x4E1A;&#x534F;&#x8BAE;&#x7B49;&#x3002;&#x534F;&#x8BAE;&#x662F;&#x5BF9;&#x53CC;&#x65B9;&#x884C;&#x4E3A;&#x51C6;&#x5219;&#x7684;&#x7EA6;&#x675F;&#xFF0C;&#x4EFB;&#x4F55;&#x4E00;&#x65B9;&#x80CC;&#x79BB;&#x65E2;&#x5B9A;&#x534F;&#x8BAE;&#x89C4;&#x5219;&#xFF0C;&#x90FD;&#x4F1A;&#x5BFC;&#x81F4;&#x53CC;&#x65B9;&#x7684;&#x5173;&#x7CFB;&#x51FA;&#x73B0;&#x95EE;&#x9898;&#x3002;&#x73B0;&#x5B9E;&#x751F;&#x6D3B;&#x7684;&#x4E2D;&#x7684;&#x534F;&#x8BAE;&#x5F62;&#x6001;&#x53EF;&#x80FD;&#x662F;&#x4E00;&#x7EB8;&#x6587;&#x4E66;&#xFF0C;&#x53C8;&#x6216;&#x8005;&#x662F;&#x53CC;&#x65B9;&#x53E3;&#x5934;&#x8FBE;&#x6210;&#x7684;&#x5171;&#x8BC6;&#xFF0C;&#x800C;&#x5728;&#x901A;&#x4FE1;&#x9886;&#x57DF;&#x4E2D;&#x534F;&#x8BAE;&#x662F;&#x53CC;&#x65B9;&#x5BF9;&#x4F20;&#x8F93;/&#x63A5;&#x53D7;&#x6570;&#x636E;&#x6D41;&#x7684;&#x7F16;&#x89E3;&#x7801;&#x5B9E;&#x73B0;&#x7B97;&#x6CD5;&#x3002;</p>
<p>&#x4F17;&#x6240;&#x5468;&#x77E5;&#xFF0C;&#x6570;&#x636E;&#x5728;&#x7F51;&#x7EDC;&#x4E0A;&#x662F;&#x4EE5;&#x5B57;&#x8282;&#x6D41;&#x7684;&#x5F62;&#x5F0F;&#x4F20;&#x8F93;&#xFF08;&#x5982;&#x82E5;&#x8F83;&#x771F;&#x70B9;&#x4E5F;&#x53EF;&#x4EE5;&#x8BF4;&#x662F;&#x4E8C;&#x8FDB;&#x5236;&#x6D41;&#xFF09;&#xFF0C;&#x800C;&#x5B57;&#x8282;&#x7684;&#x5B9A;&#x4E49;&#x662F;&#x5728;&#x6240;&#x6709;&#x8BA1;&#x7B97;&#x673A;&#x8BED;&#x8A00;&#x4E2D;&#x5B9A;&#x4E49;&#x7684;&#x90FD;&#x662F;8bit&#x3002;&#x6240;&#x4EE5;&#x53EA;&#x8981;&#x901A;&#x8FC7;&#x534F;&#x8BAE;&#x4E0D;&#x4EC5;&#x53EF;&#x4EE5;&#x7FFB;&#x8BD1;&#x7F51;&#x7EDC;&#x4E2D;&#x6570;&#x636E;&#x6D41;&#x7684;&#x4E1A;&#x52A1;&#x542B;&#x4E49;&#xFF0C;&#x53C8;&#x53EF;&#x5B9E;&#x73B0;&#x8DE8;&#x8BA1;&#x7B97;&#x673A;&#x8BED;&#x8A00;&#x7684;&#x901A;&#x4FE1;&#x3002;&#x4ECE;&#x4E8B;&#x901A;&#x4FE1;&#x5F00;&#x53D1;&#x7684;&#x670B;&#x53CB;&#x8981;&#x8C28;&#x8BB0;&#x6211;&#x4EEC;&#x8981;<strong>&#x9762;&#x5411;&#x534F;&#x8BAE;&#x7F16;&#x7A0B;</strong>&#xFF0C;&#x5728;&#x5F00;&#x53D1;&#x8FC7;&#x7A0B;&#x4E2D;&#x9047;&#x5230;&#x95EE;&#x9898;&#x5207;&#x52FF;&#x518D;&#x8D28;&#x7591;&#x662F;&#x5426;&#x8DDF;&#x5BF9;&#x65B9;&#x6240;&#x4F7F;&#x7528;&#x7684;&#x8BED;&#x8A00;&#x6709;&#x5173;&#x7CFB;&#xFF1F;&#x800C;&#x662F;&#x8981;&#x786E;&#x5B9A;&#x5BF9;&#x65B9;&#x662F;&#x5426;&#x51C6;&#x5B88;&#x901A;&#x4FE1;&#x534F;&#x8BAE;&#xFF0C;&#x81EA;&#x5DF1;&#x53C8;&#x662F;&#x5426;&#x51C6;&#x5B88;&#x4E86;&#x901A;&#x4FE1;&#x534F;&#x8BAE;&#x3002;</p>
<p>&#x76EE;&#x524D;&#x4E1A;&#x754C;&#x5DF2;&#x7ECF;&#x5B58;&#x5728;&#x5927;&#x91CF;&#x7684;&#x6807;&#x51C6;&#x534F;&#x8BAE;&#x652F;&#x6491;&#x4E86;&#x6574;&#x4E2A;&#x4E92;&#x8054;&#x7F51;&#x4E16;&#x754C;&#xFF0C;&#x8BF8;&#x5982;&#xFF1A;Http&#xFF0C;FTP&#xFF0C;SMTP&#xFF0C;MQTT&#xFF0C;&#x800C;&#x79C1;&#x6709;&#x534F;&#x8BAE;&#x66F4;&#x591A;&#x3002;&#x6240;&#x8C13;&#x201C;&#x79C1;&#x6709;&#x534F;&#x8BAE;&#x201D;&#x6307;&#x7531;&#x53CC;&#x65B9;&#x81EA;&#x884C;&#x7EA6;&#x5B9A;&#x7F16;&#x89E3;&#x7801;&#x89C4;&#x5219;&#x7684;&#x534F;&#x8BAE;&#xFF0C;&#x800C;&#x975E;&#x4E1A;&#x754C;&#x516C;&#x8BA4;&#x7684;&#x901A;&#x4FE1;&#x89C4;&#x8303;&#x3002;&#x672C;&#x7AE0;&#x8282;&#x6211;&#x4EEC;&#x4F1A;&#x5E26;&#x7740;&#x5927;&#x5BB6;&#x4E00;&#x8D77;&#x5B66;&#x4E60;&#x534F;&#x8BAE;&#x7684;&#x6B63;&#x786E;&#x5904;&#x7406;&#x65B9;&#x5F0F;&#xFF0C;&#x5C3D;&#x7BA1;&#x7F16;&#x89E3;&#x7801;&#x4E0D;&#x662F;&#x4E00;&#x4EF6;&#x96BE;&#x4E8B;&#xFF0C;&#x4F46;&#x5BF9;&#x4E8E;&#x65B0;&#x624B;&#x670B;&#x53CB;&#x8FD9;&#x4E5F;&#x5E76;&#x4E0D;&#x7B80;&#x5355;&#x3002;&#x5982;&#x679C;&#x60A8;&#x5BF9;&#x4E8E;&#x534A;&#x5305;&#x3001;&#x7C98;&#x5305;&#x7684;&#x5904;&#x7406;&#x65B9;&#x5F0F;&#x8FD8;&#x4E0D;&#x751A;&#x4E86;&#x89E3;&#xFF0C;&#x4E0D;&#x59A8;&#x597D;&#x597D;&#x9605;&#x8BFB;&#x672C;&#x7AE0;&#x5185;&#x5BB9;&#xFF0C;&#x4EE5;&#x540E;&#x4E5F;&#x8BF7;&#x52FF;&#x629B;&#x51FA;&#x6B64;&#x7C7B;&#x95EE;&#x9898;&#xFF0C;&#x56E0;&#x4E3A;&#x8FD9;&#x6BD4;&#x8F83;&#x201D;&#x4E0D;&#x4E13;&#x4E1A;&#x201C;&#x3002;</p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; smartboot.org 2018 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2019-07-07 13:12:00
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../chapter-2/SUMMARY.html" class="navigation navigation-prev " aria-label="Previous page: 2.5 小结">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="1-消息归类/" class="navigation navigation-next " aria-label="Next page: 3.1 消息归类">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"第三章 通信协议","level":"1.2.4","depth":2,"next":{"title":"3.1 消息归类","level":"1.2.4.1","depth":3,"path":"smart-socket/chapter-3/1-消息归类/README.md","ref":"smart-socket/chapter-3/1-消息归类/README.md","articles":[]},"previous":{"title":"2.5 小结","level":"1.2.3.5","depth":3,"path":"smart-socket/chapter-2/SUMMARY.md","ref":"smart-socket/chapter-2/SUMMARY.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-lunr","-search","-sharing","search-plus","expandable-chapters-interactive","tbfed-pagefooter","github","github-buttons","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy smartboot.org 2018","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"github":{"url":"https://github.com/smartboot/smart-socket"},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"expandable-chapters-interactive":{},"github-buttons":{"buttons":[{"user":"smartboot","repo":"smart-socket","type":"star","size":"small","count":true}]},"edit-link":{"label":"Edit This Page","base":"https://gitee.com/smartboot/book/edit/master"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"search-plus":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"smartboot 中文指南","language":"en","gitbook":"*","description":"本文涵盖了smartboot下所有项目的技术手册"},"file":{"path":"smart-socket/chapter-3/README.md","mtime":"2019-07-07T05:12:00.684Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2020-04-02T05:22:17.739Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters-interactive/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

